//获取热门数据并且创建在页面上
$.ajax({
		type: "get",
		url: "http://localhost:2333/data/remen.json",
		success: function(date) {
			for (var i = 0; i < date.result.length; i++) {
				$("<a href='#'><img src=" + date.result[i].img_url + "></a>").appendTo($("#rm"))
			}
//			console.log(date)
		}
	})
//获取精选数据并且创建在页面上
$.ajax({
		type: "get",
		url: "http://localhost:2333/data/jingxuan.json",
		success: function(aaa) {
			for (var i = 0; i < aaa.result1.length; i++) {
				$('<a href="#"><img src=' + aaa.result1[i].thum_img.old + '></a>').appendTo($("#yp"))
			}
//			console.log(aaa)
		}
})
//xiushouji
$.ajax({
		type: "get",
		url: "http://localhost:2333/data/chengshi.json",
		success: function(city) {
			for (var i = 0; i < city.result.hotcity.length; i++) {
				$('<span>'+city.result.hotcity[i].name +'</span>').appendTo($("#c-hot"))
			}
//			console.log(city)
		}
})
//点击切换城市
$.ajax({
		type: "get",
		url: "http://localhost:2333/data/chengshi.json",
		success: function(cl) {
			var abc=cl.result.citylist["A"];
			console.log(typeof(csc))
			for(var i = 0; i < abc.length; i++){
				$('<span>'+abc[i].name +'</span>').appendTo($("#city-4"))
			}

		}
	})
$("#py span").on("click",function(){
	$("#city-4 span").remove()
	$(this).css("color","orange")
//	$(this).siblings.css("color","black")
	var x=$(this).html()
//	console.log(x)
	$.ajax({
		type: "get",
		url: "http://localhost:2333/data/chengshi.json",
		success: function(cl) {
			var csc=cl.result.citylist[x];
			console.log(typeof(csc))
			for(var i = 0; i < csc.length; i++){
				$('<span>'+csc[i].name +'</span>').appendTo($("#city-4"))
			}

		}
	})
})
//点击出现

$("#cslb").on("click",function(){
	$("#city").css("display","block")
})
$("#l-closs").on("click",function(){
	$("#city").css("display","none")
})

//轮播图左侧列表
$("#tab-list li").eq(0).hover(f1,f2);
	function f1(){
		$("#xsj").css("display","block")
	}
	function f2(){
		$("#xsj").css("display","none")
	}
$("#tab-list li").eq(1).hover(f3,f4);
	function f3(){
		$("#xdn").css("display","block")
	}
	function f4(){
		$("#xdn").css("display","none")
	}
$("#tab-list li").eq(2).hover(f5,f6);
	function f5(){
		$("#msj").css("display","block")
	}
	function f6(){
		$("#msj").css("display","none")
	}
$("#tab-list li").eq(3).hover(f7,f8);
	function f7(){
		$("#messj").css("display","block")
			}
	function f8(){
		$("#messj").css("display","none")
			}
		
//获取修手机数据
$.ajax({
		type: "get",
		url: "http://localhost:2333/data/xiushouji.json",
		success: function(xsj) {
			for (var i = 0; i < xsj.result.length; i++) {
				var pp=$('<p><span class="q1">'+xsj.result[i].name+'</span></p>').appendTo($("#xsj"))
				var ss=xsj.result[i].list
//				console.log(ss)
//				console.log(ss.length)	
			for(var j = 0 ;j < ss.length;j++){
//				console.log(ss[j])
				$("<span>"+ss[j].name+"</span>").appendTo( pp )
				}			
			}
							
//			console.log(xsj)
		}
})
//获取修电脑数据
$.ajax({
		type: "get",
		url: "http://localhost:2333/data/diannaoweixiu.json",
		success: function(xdn) {
//			console.log(xdn.result.hot)
			for (var i = 0; i < xdn.result.hot.length; i++) {
				$('<span>'+xdn.result.hot[i].name+'</span>').appendTo($("#xdn1 p"))			
			
			}
			for (var i = 0; i < xdn.result.other.length; i++) {
				$('<span>'+xdn.result.other[i].name+'</span>').appendTo($("#xdn2 p"))			
			}
			
//			console.log(xdn)
		}
})
//获取卖手机收据
$.ajax({
		type: "get",
		url: "http://localhost:2333/data/maishouji.json",
		success: function(msj) {
			for (var i = 0; i < msj.result.length; i++) {
				$('<span>'+msj.result[i].name+'</span>').appendTo($("#msj p"))			
			}
//			console.log(msj)
		}
})
//获取二手手机数据
$.ajax({
		type: "get",
		url: "http://localhost:2333/data/maiershoushouji.json",
		success: function(essj) {
			for (var i in essj.result) {
				$('<span>'+essj.result[i]+'</span>').appendTo($("#messj p"))			
			}
//			console.log(essj)
		}
})
